<?php
namespace Common\Behavior;

class CheckLoginBehavior extends \Think\Behavior {
    public function run(&$opt) {
        if(CONTROLLER_NAME == 'Index' && in_array(ACTION_NAME , array('login', 'doLogin'))) {
            return true;
        }

        $userModel = D('User');

        if(!$user = $userModel->getLoginUser()) {
            header('Location:' . C('LOGIN_URL'));
        }

        C('RUN_LOGIN_USER', $user);
    }
}
